package com.migu.spms.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.migu.spms.dao.entity.UserInfoCriteria;
import com.migu.spms.dao.entity.UserInfoDO;
import com.migu.spms.dao.inf.IUserInfoDO;
import com.migu.spms.service.data.UserInfoVO;
import com.migu.spms.service.inf.IUserInfoService;
@Component("userInfoService")
public class UserInfoServiceImpl implements IUserInfoService{
	@Resource(name="IUserInfoDO")
	private IUserInfoDO userInfoDao;

	@Override
	public UserInfoVO queryUserInfoByUid(Long uid) {
		UserInfoDO userInfo=userInfoDao.queryUserInfoByUid(uid);
		UserInfoVO userInfoVO=com.migu.spms.utils.PropertiesCopyUtil.parse(userInfo, UserInfoVO.class);
		userInfoVO.setDepartmentid(userInfo.getDepartmentDO().getDepartmentId());
		userInfoVO.setDepartmentName(userInfo.getDepartmentDO().getDepartmentName());
		userInfoVO.setCompanyid(userInfo.getCompanyid());
		userInfoVO.setCompanyName(userInfo.getCompanyDO().getCname());
		userInfoVO.setRoleName(userInfo.getRoleDO().getRname());
		return userInfoVO;
	}

	@Override
	public UserInfoVO queryUserInfoByCriteria(UserInfoCriteria record) {
		UserInfoDO userInfo=userInfoDao.queryUserInfoByCriteria(record);
		UserInfoVO userInfoVO=com.migu.spms.utils.PropertiesCopyUtil.parse(userInfo, UserInfoVO.class);
		userInfoVO.setDepartmentid(userInfo.getDepartmentDO().getDepartmentId());
		userInfoVO.setDepartmentName(userInfo.getDepartmentDO().getDepartmentName());
		userInfoVO.setCompanyid(userInfo.getDepartmentDO().getCompanyId());
		userInfoVO.setCompanyName(userInfo.getCompanyDO().getCname());
		userInfoVO.setRoleName(userInfo.getRoleDO().getRname());
		return userInfoVO;
	}

}
